package stanford.com.balldating.chat.websocket;

import java.util.Map;

import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

import com.project.framework.util.URLUtils;

public class WebSocketHandshakeInterceptor implements HandshakeInterceptor {
  
  public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler,
			Map<String, Object> attrs) throws Exception {
		// TODO Auto-generated method stub

	  		Map<String,String> param=URLUtils.URLRequest(request.getURI().toString());
	  		
	  		String username=param.get("username");
	  		
	  		if(username!=null&&!username.trim().equals("")){
	  			attrs.put("username", username);
	  		}
		   	
		   	return true;
			
		}

   public void afterHandshake(ServerHttpRequest arg0, ServerHttpResponse arg1, WebSocketHandler arg2, Exception arg3) {
		// TODO Auto-generated method stub
		
	}
}
